<?php
//
//	file: includes/aucp/color_functions.php
//	begin: 30/04/2007
//	$Author: christopher $
//	$Revision: 29 $
//	$Date: 2008-07-19 15:59:35 +0000 (Sat, 19 Jul 2008) $
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	description: colors functions

if (!defined('IN_PHPBB'))
{
	die("Hacking attempt");
}

function color_search()
{
	global $template, $user, $theme;

	$page_title = $user->lang('AGCM_color_search');

	$template->set_filenames(array(
		'search_color' => 'search_color.tpl')
	);

	$template->assign_vars(array(
		'L_WEB_SAFE' => $user->lang('AGCM_web_safe'),
		'L_WINDOWS_SYSTEM' => $user->lang('AGCM_windows_system'),
		'L_GREY_SCALE' => $user->lang('AGCM_grey_scale'),
		'L_MAC_OS' => $user->lang('AGCM_mac_os'),
		'PAGE_TITLE' => $page_title,
		'S_CONTENT_DIRECTION' => $user->lang('DIRECTION'),
		'S_CONTENT_ENCODING' => $user->lang('ENCODING'),
		'T_BODY_BGCOLOR' => '#'.$theme['body_bgcolor'])
	);

	$template->pparse('search_color');

	return;
}

function group_color_select()
{
	global $view_user, $user, $db;

	$list_color = array();

	$sql = 'SELECT group_id
			FROM ' . GROUPS_TABLE . '
			WHERE group_color = 1
				AND group_id = ' . GROUP_REGISTERED;
	$result = $db->sql_query($sql, false, __LINE__, __FILE__);

	if ( $row = $db->sql_fetchrow($result) )
	{
		$list_color[GROUP_REGISTERED] = 'Group_registered';
	}

	$db->sql_freeresult($result);

	if ( empty($view_user) )
	{
		$user_id = $user->data['user_id'];
	}
	else
	{
		$user_id = $view_user->data['user_id'];
	}

	$sql = 'SELECT g.group_id, g.group_name
			FROM ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g
			WHERE ug.user_id = ' . intval($user_id) . '
				AND g.group_id = ug.group_id
				AND g.group_color = 1
				AND ug.user_pending <> 1
			ORDER BY g.group_weight ASC';
	$result = $db->sql_query($sql, false, __LINE__, __FILE__);

	while ( $group_data = $db->sql_fetchrow($result) )
	{
		$list_color[ intval($group_data['group_id']) ] = $group_data['group_name'];
	}

	$db->sql_freeresult($result);

	return $list_color;
}

?>